from flask import Flask
from flask import request
from dada import post_dada_api
app = Flask(__name__)

@app.route('/', methods=['GET'])
def say_hello():
    return "hello dada"

@app.route('/dada', methods=['POST'])
def print_json():

    result = request.form
    dict_form = result.to_dict()
    result = post_dada_api(**dict_form)
    if(result == b''):
        return '''返回空'''
    else:
        return result



@app.route('/dada', methods=['GET'])
def order_form():
    #订单编号 + 模拟订单接口： 1. 模拟接受订单 2.模拟完成取货 3.模拟完成订单 4.模拟取消订单 5.模拟订单过期
    return '''<form action="/dada" method="post">
              <p>订单号:</br>
              <input name="order_number" value="">
              </p>
              <input type="radio" name="api_type" value="1" checked>模拟骑手接单
              <input type="radio" name="api_type" value="2">模拟骑手完成取货
              <input type="radio" name="api_type" value="3">模拟骑手完成订单
              <input type="radio" name="api_type" value="4">模拟达达取消订单
              <input type="radio" name="api_type" value="5">模拟达达订单过期
              <p>商户ID:73753</p>
              <p>门店编号:11047059</p>
              <p></br><p><button type="submit">Submit</button></p>
              </form>'''

if __name__ == '__main__':
    app.run(host='0.0.0.0',port=8888)